package jespeak.dict;

import java.util.ArrayList;
import java.util.List;

public class Dictionary {

	private String list_file;
	private List<DictRule> map;
	private List<Character> vowels;
	
	public Dictionary(String lfile) {
		list_file = lfile;
		map = new ArrayList<DictRule>();
		// brutal, just english for now
		vowels = new ArrayList<Character>();
		vowels.add('a');
		vowels.add('e');
		vowels.add('o');
		vowels.add('i');
		vowels.add('u');
	}

	public boolean isVowel(char c) {
		return vowels.contains(c);
	}

	public boolean isConsonant(char c) {
		return !isVowel(c);
	}
	
	public void addDictRule(DictRule r) {
		map.add(r);
	}

	public DictRule find(String word) {
		int i, s = map.size();
		for (i = 0; i < s; ++i) {
			DictRule dr = map.get(i);
			if (dr.getWord().equals(word)) {
				if (dr.getPhoneme() != null) {
					return dr;
				}
			}
		}
		return null;
	}

	@Override
	public String toString() {
		String s = map.toString();
		return s;
	}

	void print() {
		int i, s = map.size();
		for (i = 0; i < s; ++i) {
			System.out.println(map.get(i).getWord() + " " + map.get(i).getPhoneme());
		}
	}
}